package cn.wolfcode.tieba.service.impl;

import cn.wolfcode.tieba.domain.Reply;
import cn.wolfcode.tieba.mapper.ReplyMapper;
import cn.wolfcode.tieba.query.ReplyQuery;
import cn.wolfcode.tieba.service.IReplyService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
* 回复表服务接口实现
*/
@Service
@Transactional
public class ReplyServiceImpl extends ServiceImpl<ReplyMapper,Reply> implements IReplyService  {

    @Override
    public IPage<Reply> queryPage(ReplyQuery qo) {
        IPage<Reply> page = new Page<>(qo.getCurrentPage(), qo.getPageSize());
        QueryWrapper<Reply> wrapper = Wrappers.<Reply>query();
        return super.page(page, wrapper);
    }

    @Override
    public List<Reply> listById(Long postedId) {
        QueryWrapper<Reply> wrapper = new QueryWrapper<>();
        wrapper.eq("posted_id",postedId);
        return super.list(wrapper);
    }
}
